package com.imaker.action;

import java.io.File;
import java.util.List;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import org.apache.struts2.ServletActionContext;

import com.imaker.domain.Page;
import com.opensymphony.xwork2.ActionSupport;

 /**
 * <p>程序名称：       Action的基类BaseAction.java</p>
 * <p>程序说明：       该Action封装了一些通用的参数，如果要使用这些参数，只需继承该Action即可</p>
 * <p>版权信息：       Copyright mayonghua</p>
 * <p>时间：          Oct 21, 2010 3:04:52 PM</p>	
 * 
 * @author：          mayonghua
 * @version：         Ver 0.1
 */

public class BaseAction extends ActionSupport {
 
	private static final long serialVersionUID = 1L;
	
	protected HttpServletRequest request;
	protected HttpServletResponse response;
	protected HttpSession session;
	protected List<File> upload;//文件上传
	protected List<String> uploadFileName;//上传的文件名
	protected List<String> uploadContentType;//上传文件的类型
	protected List<String> idList;//条目在数据库中的主键ID
	protected static String path = "upload";
	protected Page page = new Page();
	
	@SuppressWarnings("deprecation")
	public static String getPath() {
		return ServletActionContext.getRequest().getRealPath(path);
	}
//	得到web-inf的绝对路径
	public static String getConfigPath() {
		return ServletActionContext.getRequest().getRealPath("WEB-INF");
	}
//	得到code目录的绝对路径
	public static String getCodePath(){
		return ServletActionContext.getRequest().getRealPath("code");
	}
	public HttpServletRequest getRequest() {
		return ServletActionContext.getRequest();
	}
	public void setRequest(HttpServletRequest request) {
		this.request = request;
	}
	public HttpServletResponse getResponse() {
		return ServletActionContext.getResponse();
	}
	public void setResponse(HttpServletResponse response) {
		this.response = response;
	}
	public HttpSession getSession() {
		return ServletActionContext.getRequest().getSession();
	}
	public void setSession(HttpSession session) {
		this.session = session;
	}
	public List<File> getUpload() {
		return upload;
	}
	public void setUpload(List<File> upload) {
		this.upload = upload;
	}
	public List<String> getIdList() {
		return idList;
	}
	public void setIdList(List<String> idList) {
		this.idList = idList;
	}
	public List<String> getUploadFileName() {
		return uploadFileName;
	}
	public void setUploadFileName(List<String> uploadFileName) {
		this.uploadFileName = uploadFileName;
	}
	public List<String> getUploadContentType() {
		return uploadContentType;
	}
	public void setUploadContentType(List<String> uploadContentType) {
		this.uploadContentType = uploadContentType;
	}
	public static void setPath(String path) {
		BaseAction.path = path;
	}
	public Page getPage() {
		return page;
	}
	public void setPage(Page page) {
		this.page = page;
	}
	
}
